// pages/paihang/paihang.js
const app = getApp()
Page({
  /**
   * 页面的初始数据
   */
  data: {
      paihang: [],
      img1:"/images/xin.png",
      cid:""
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
      wx.startPullDownRefresh()
  },
  onShow: function () {
     
  },
  changeColor: function (res) {
      var paihang = this.data.paihang.slice(0);
      var tL = paihang.length
      for (var i = 0; i < tL; i++) {
          if (res.target.id == paihang[i].article_id ) {
              if (res.target.id == paihang[i].article_id) {
                  if (paihang[i].is_share == "true") {
                      paihang[i].is_share = "false"
                      paihang[i].sun--
                  } else {
                      paihang[i].is_share = "true"
                      paihang[i].sun++
                  }
              }
          }
      }
      this.setData({
          paihang: paihang
      })
      var that = this
      wx.request({
          url: 'https://www.mayizhihuan.com/Home/Articlelittle/conllection/',
          data: {
              article_id: res.target.id,
              PHPSESSID: wx.getStorageSync('sid')
          },
          method: 'GET',
          header: {
              'content-type': 'application/json'
          },
          success: function (res) {
              
          }
      })
  
  },
  details: function (e) {
      wx.navigateTo({
          url: '../details/details?id=' + e.target.id
      })
      var that = this
      wx.request({
          url: 'https://www.mayizhihuan.com/Home/Articlelittle/',
          data: {
              id: e.target.id,
              PHPSESSID: wx.getStorageSync('sid')
          },
          method: 'GET',
          header: {
              'content-type': 'application/json'
          },
          success: function (res) {
              
          }
      })
  },
jiazai:function(){
    var that = this
    wx.request({
        url: 'https://www.mayizhihuan.com/Home/Runking/',
        data: {
            PHPSESSID: wx.getStorageSync('sid')
        },
        method: 'GET',
        header: {
            'content-type': 'application/json'
        },
        success: function (res) {
            that.setData({
                paihang: res.data.datas
            })
        }
    })
},
  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  //下拉刷新
  onPullDownRefresh: function () {
      wx.showNavigationBarLoading() //在标题栏中显示加载
      //模拟加载
      this.jiazai();
      setTimeout(function () {
          // complete
          wx.hideNavigationBarLoading() //完成停止加载
          wx.stopPullDownRefresh() //停止下拉刷新
      }, 1000);
  },
  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})